fix(ship): discharge check uses PR ref presence (gh doesn't surface PR state) - #463
Merged
Merged
Conversation
…R state) The classifier was checking `ref.state === "MERGED"` against entries in `closedByPullRequestsReferences`, but `gh issue view` does not surface the linked PR's state — the array only carries id/number/url/repository. Result: every discharged sub-issue was misclassified as `closed-orphan`, halting the orchestrator on the first re-fire. Fix: presence of any PR ref on a CLOSED issue is sufficient signal. GitHub only populates `closedByPullRequestsReferences` when a PR's "Closes #N" keyword triggered the close — which implies a merge action happened. If the PR were later reverted, the issue would re-open and the `state === CLOSED` branch wouldn't fire. Discovered when re-firing `ship run 426` after #461 landed — V-1's discharge check (issue #427 closed by merged PR #448) returned `closed-orphan` instead of `discharged`, halting the orchestrator. Updated tests reflect the verbatim `gh` JSON shape (no `state` field on PR refs) and drop the "PR not merged" / "prefers first MERGED" test cases that are no longer reachable. Refs #454. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #461 — the discharge check I wrote there had a bug that became visible the first time it ran against real GH data.
What was wrong
`classifyGhSubIssueState` checked `ref.state === "MERGED"` against entries in `closedByPullRequestsReferences`. But `gh issue view --json state,closedByPullRequestsReferences` doesn't surface each PR's state — the array entries carry only `id`, `number`, `url`, `repository`. The state check never matched, so every discharged sub-issue was misclassified as `closed-orphan`.
Surfaced on the first re-fire of `ship run 426` after #461 landed:
```
halted_reason: "sub-issue lambda-brahman/ship#23 (V-1) is closed without a merged PR — operator decision needed"
```
…even though V-1's lambda-brahman/ship#23 was clearly closed by merged PR #448.
Fix
Drop the per-ref state check. Presence of any PR ref on a CLOSED issue is sufficient signal: GitHub only populates `closedByPullRequestsReferences` when a PR's "Closes #N" keyword triggered the close, which implies a merge happened. (If the PR were later reverted, the issue would re-open and the `state === CLOSED` branch wouldn't fire.)
Test updates
Refs lambda-brahman/ship#2.
🤖 Generated with Claude Code